﻿using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using PhysicsEngine.Collision;
using PhysicsEngine.Collision.Shapes;
using PhysicsEngine.Common;

namespace PhysicsEngine.Dynamics
{
  public class Body : IBody
  {
    public IShape Shape { get; private set; }
    public Transform XForm { get; private set; }
    public Material Material { get; private set; }

    private MassData _massData;
    //private Vector2 _velocity;
    //private Vector2 _force;

    public Body(IShape shape, Vector2 position, Material material)
    {
      Contract.Ensures(Shape == shape);
      Contract.Ensures(Material == material);
      Contract.Ensures(XForm.Position == position);

      Shape = shape;
      Material = material;
      XForm = new Transform(position);
    }

    [ContractInvariantMethod]
    private void ObjectInvariant()
    {
      Contract.Invariant(Shape != null);
      Contract.Invariant(Material != null);
      Contract.Invariant(XForm != null);
    }

    public void SetMassFromShape()
    {
      _massData = Shape.ComputeMass(Material.Density);
    }

    public AABB GetAABB()
    {
      throw new NotImplementedException();
    }
  }
}
